<?php

if($_POST['bargain_amount']=="") {
	echo "<div id='err-msg'>Enter bargain amount</div>";
}
else if(is_numeric($_POST['bargain_amount'])) {
	
	$bamt = $_POST['bargain_amount'];
	if($bamt!="") {			
		$qry="SELECT * FROM tbl_bargain where product_id='$proId' and user_id='1'";
		$res=mysql_query($qry);
		if(mysql_num_rows($res) > 0) {			
			echo "<div id='rst-bargain'>Already Placed.</div>";
		}
		else {
			$sql="INSERT INTO tbl_bargain set product_id='$proId', user_id='1', amount='$bamt'";
			$rst=mysql_query($sql);
			if($rst) { echo "<div id='suc-msg'>Bargain placed successfully.</div>"; }
			else { echo "<div id='err-msg'>Error on placing your bargain.</div>"; }
		}				
	}	
}		
else {
	echo "<div id='err-msg'>Enter valid amount</div>";
}		
				
?>
			


